package exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        String src= null,str="abc";
        try {
            System.out.println(src.length());
            System.out.println(str.charAt(3));
            System.out.println(Integer.parseInt(str));
            System.out.println("!!!!!!!!!");
        } catch (NullPointerException | StringIndexOutOfBoundsException e) {
            System.out.println("异常信息：" + e.getMessage());
        } catch (Exception e) {
            System.out.println("无论如何出错了!");
        }
        /*catch (NullPointerException e) {
            System.out.println("空指针异常");
            //e.printStackTrace();
        } catch (StringIndexOutOfBoundsException e) {
            System.out.println("索引越界异常");

        }

         */
        System.out.println("程序结束了");
    }
}
